PART DESCRIPTION | VENDOR PART | PRICE (1998) | QUANTITY |
8255 PPI 40 PIN IC | JAMECO #52417 | 3.95 | 1 |
40 PIN WIREWRAP SOCKET | JAMECO #41179 | 1.65 | 1 |
74HCT138 3-TO-8 DECODER | JAMECO #44927 | 0.29 | 1 |
16-PIN SOLDER SOCKET | JAMECO #37372 | 0.12 | 1 |
0.1 uF CAPACITORS | JAMECO #15270 | 1.00 FOR 10 | 3 |
40 PIN HEADER CONNECTOR | DIGIKEY #CHW40G-ND | 5.11 | 2 |
40 PIN SOCKET CONNECTOR | DIGIKEY #CSC40T-ND | 2.45 | 2 |
2 ROW 8-POSITION JUMPER | JAMECO #109516 | 0.39 | 1 |
SHORTING BLOCKS | JAMECO #22023 | 0.20 | 2 |
PC BUS PROTOTYPING CARD | JAMECO #21531 | 17.95 | 1 |
RIBBON CABLE 40 PIN | JAMECO #105726 | 20.00 FOR 25 FT | 3 FT |
WIRE WRAP |
PART DESCRIPTION | VENDOR PART | PRICE (1995) | QUANTITY |
6 IN. SOLDERLESS BREADBOARD | RADIO SHACK #276-174 | 12.49 | 2 |
74LS04 HEX INVERTOR | JAMECO #46316 | 0.29 | 1 |
LEDS T1-3/4 | JAMECO #34745 | 0.19 | 8 |
220 OHM RESISTORS | |||
TERMINAL BLOCKS | JAMECO #99426 | 0.59 | 14 |
ADDRESS (HEX/DEC) | DESCRIPTION | ADDRESS (HEX/DEC) | DESCRIPTION |
218-21F (536-543) | AVAILABLE | 390-39F (906-927) | AVAILABLE |
250-277 (592-631) | AVAILABLE | 3AA-3AF (938-943) | AVAILABLE |
280-2EF (640-751) | AVAILABLE | 3B0-3BF (944-959) | AVAILABLE |
300-31F (768-799) | AVAILABLE | 3F8-3FF | COM 1 |
For notation purposes, a number with an H next to it denotes hexadecimal notation and plain numbers will denote denote plain decimal. For this card, I chose to use 280H (640 Decimal) for the address of the card. This is because many other cards tend to use the traditional 300H. By choosing 280H the probability of address conflict is a bit less. Thus 280H will known as the base address of the card. Of course, you can change this, by using the table above as a guide, and physically changing the jumper configuration on the board, as well as in your software program.
Each port is 8-bit TTL-compatiable. As such, the 8255 can conceivable be configured to control 24 devices (1 bit/device). The various modes can be set by writing a special value to the control port. The control port is Base Address + 3 (hence 640+3 = 643 Decimal). The table below shows the special values needed to configure Ports A, B and C for either input or output:
CONTROL WORD (HEX) | CONTROL WORD (DECIMAL) | PORT A | PORT B | PORT C |
80 | 128 | OUT | OUT | OUT |
82 | 130 | OUT | IN | OUT |
85 | 137 | OUT | OUT | IN |
87 | 139 | OUT | IN | IN |
88 | 144 | IN | OUT | OUT |
8A | 146 | IN | IN | OUT |
8C | 153 | IN | OUT | IN |
8F | 155 | IN | IN | IN |
As mentioned the Control Port is Base Address + 3. Port A is always at Base Address; Port B is Base Address + 1; Port C is Base Address + 2. Thus in our example Ports A, B and C are at 640, 641 and 642 (Decimal) respectively. By writing say, 128 to the Control port will then configure the 8255 to have all three Ports set for output. This can be done using QuickBasic's OUT statement, for example:
110 BaseAddress = 640 |
120 PortA = BaseAddress |
130 ControlPort = BaseAddress + 3 |
140 OUT ControlPort, 128 |
150 OUT PortA, 1 |
More software coding will be described later in the Programming Section.
Altogether there are 62 pads on this card. Such cards are also known as 8-bit ISA Bus (XT-style) cards. Due to the upward compatiability of PC systems, such cards can plug into expansion slots on XTs, ATs, 386s, 486s and Pentiums. The following diagram shows the pinouts of such expansion slots:
Getting back to the 74LS138... address lines A8 and A9 on the bus drive the control inputs to the 74LS138. Additionally, AEN (Address Enable), located at pin A11 is low when the card is recognized by the microprocessor. When A8 and A11 is low and A9 is high, the 74LS138 will decode bus address lines A5, A6 and A7 which are the 3-bit inputs to the 74LS138. The following picture may provide more insight:
As a result, we can see that the jumper provides for 8 possible card address lines listed in the above figure. This in comparision with TABLE 2 shows that the only available only jumper position 5 is fully available, corresponding to 280H ((640).
You can click below to download the Adobe Acrobat format of the schematic. I've tried to get a more generic format e.g. GIF or PS but with no success (as seen to above fuzzy picture). I tried to provide a Windows Meta File format but have found bad results e.g. doesn't load into Word well. If you don't know what Acrobat is, visit Adobe to download a copy of its FREE PDF-file viewer.
Download the Acrobat (PDF) file of the schematic. Recommended! 10884 Bytes
Figure A
This figure shows the overall view of the card and the component placement. If one looks closely, one can see the label 1 on both the 40-pin header and its ribbon cable (see also Figure C). Also the jumpers clearly show how jumper 5 has been shorted with a shorting block. One can also see the "tedious" soldering required along the card's pads (see Figure D as well). Again I emphasize that these pads represent pins A1 to A31 of the card (component side).
Figure B
This is the solder side. This view was provided to show the wirewrapping involved. For clarity during construction, I placed labels for pin 1 on both the 8255 wirewrapping socket and the 40-pin header. Recall that with this 40-pin header, one row represented all odd numbers i.e. the ribbon's 1st, 3rd, 5th, 7th etc wire, while the other row represents all the even numbers, i.e. the ribbon's 2nd, 4th, 6th etc wire.
Figure C
Another view of the 40-pin header, but with the ribbon cable detached. Note that this is a polarized type of header socket.
Figure D
This is a clearer view of the prototyping card's 31 pins (A1-A31) and the soldering/wiring involved.
This section is necessary for two reasons. First, this breadboarding inteface provides a way to test your 8255 card. Second, it facilitates the accessability of the 24 I/O lines by using the breadboard and screw terminal blocks. As the Figure (top) shows, the 24 I/Os are brought out from a 40-pin header to the terminal blocks, all on a single breadboard. Recall that in the card's construction in the sections above a 40-pin ribbon cable and header connector were used to connect to the 8255's Ports A, B and C. It is this opposite end of the ribbon cable that is brought to the breadboard and terminal blocks. It is simply a matter of matching up the correct ribbon wire with a terminal block. The Figure (botton) also shows a simple test circuit, the schematic of which is provided below. It uses all 8-bits of Port A configured for output. The Programming section below will show how to light up the LEDs, which would indicate that Port A is working properly.
100 REM 8255 PPI SET PORTS A,B,C TO OUTPUT |
110 BASEADDR = 640: REM 280H/JUMPER AT POSITION 5 |
120 PORTA = BASEADDR |
130 CNTRL = BASEADDR + 3 |
140 OUT CNTRL, 128 |
150 FOR SGNAL = 0 TO 255 |
160 OUT PORTA, SGNAL:PRINT "DECIMAL="; SGNAL |
170 FOR DELAY = 1 TO 500: NEXT DELAY |
180 NEXT SGNAL |
999 END |
If everything has been assembled correctly and the software properly compiled, then one should see the 8 LEDs should "count" from 0 to 255 in a binary fashion.
Congradulations if you have gotten this far! In my experience troubleshooting should begin in checking if the card is seated nicely in its slot on the motherboard. Also check the jumper. Check your wiring.
Of course the above is a simple circuit, but I leave it to your imagination to come up with other possibilities given that you have 24 digital inputs and outputs. Things like motor speed control, switching on relays, reading thermistors, strain gages etc.